<template>
  <a-modal v-bind:visible="isShowJuri" title="批量修改权限" @cancel="onCancel">
    <p class="text">请谨慎操作！</p>
    <template slot="footer">
      <a-button key="back" @click="off"> 账号禁用 </a-button>
      <a-button key="submit" type="primary" @click="open"> 账号启用 </a-button>
    </template>
  </a-modal>
</template>

<script>
import { editJuriAPI } from '@/api/userinfo.js'
export default {
  name: 'EditJuri',
  props: {
    isShowJuri: {
      type: Boolean,
      default: false
    },
    ids: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {}
  },
  methods: {
    onCancel() {
      this.$emit('update:isShowJuri', false)
    },
    async open() {
      await editJuriAPI({ brand_id: process.env.VUE_APP_BRAND_ID, status: 1, user_ids: this.ids })
      this.$emit('upload')
      this.$emit('update:isShowJuri', false)
      this.$message.success('修改成功')
    },
    async off() {
      await editJuriAPI({ brand_id: process.env.VUE_APP_BRAND_ID, status: 0, user_ids: this.ids })
      this.$emit('upload')
      this.$emit('update:isShowJuri', false)
      this.$message.success('修改成功')
    }
  }
}
</script>

<style lang="less" scoped>
.text {
  color: red;
}
</style>
